home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.multimedia;
-
- import java.io.IOException;
- import java.io.InputStream;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.net.URLConnection;
- import java.util.Vector;
- import sun.audio.AudioStream;
-
- public class SoundPlayer {
- private Vector clips = new Vector();
- private boolean sync = true;
- private SoundViewerThread spt;
- private int repeatCt = 1;
- public static final int INFINITE = -1;
-
- public void setSyncMode(boolean var1) {
- this.sync = var1;
- if (this.spt != null) {
- this.spt.doSync(var1);
- }
-
- }
-
- public boolean getSyncMode() {
- return this.sync;
- }
-
- public void setRepeat(int var1) {
- this.repeatCt = var1;
- }
-
- public int getRepeat() {
- return this.repeatCt;
- }
-
- public void addURL(URL var1) {
- InputStream var2 = null;
-
- try {
- try {
- URLConnection var5 = var1.openConnection();
- var5.setAllowUserInteraction(true);
- var2 = var5.getInputStream();
- AudioStream var6 = new AudioStream(var2);
- this.clips.addElement(new SoundViewerItem(var6.getData(), (int)((double)var6.getLength() / (double)7168.0F * (double)1000.0F)));
- } finally {
- if (var2 != null) {
- var2.close();
- }
-
- }
-
- } catch (IOException var10) {
- }
- }
-
- public void addStringURL(String var1) {
- try {
- this.addURL(new URL(var1));
- } catch (MalformedURLException var2) {
- }
- }
-
- public void setURLList(URL[] var1) {
- this.clips.removeAllElements();
-
- for(int var2 = 0; var2 < var1.length; ++var2) {
- this.addURL(var1[var2]);
- }
-
- }
-
- public URL[] getURLList() {
- int var1 = this.clips.size();
- URL[] var2 = new URL[var1];
-
- for(int var3 = 0; var3 < var1; ++var3) {
- var2[var3] = (URL)this.clips.elementAt(var3);
- }
-
- return var2;
- }
-
- public void play() {
- this.spt = new SoundViewerThread(this.clips, this.sync, this.repeatCt);
- this.spt.start();
- }
-
- public void stop() {
- if (this.spt != null) {
- this.spt.doStop();
- }
-
- }
-
- public void stop(int var1) {
- try {
- Thread.sleep((long)var1);
- } catch (InterruptedException var2) {
- }
-
- this.stop();
- }
- }
-